﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace DataEntity.Entities
{
    public partial class WEBDBContext : DbContext
    {
        public WEBDBContext()
        {
        }

        public WEBDBContext(DbContextOptions<WEBDBContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Tcomment> Tcomment { get; set; }
        public virtual DbSet<TmessCategory> TmessCategory { get; set; }
        public virtual DbSet<Tmessage> Tmessage { get; set; }
        public virtual DbSet<Uinformation> Uinformation { get; set; }
        public virtual DbSet<Userinfo> Userinfo { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
                optionsBuilder.UseSqlServer("Server=.;Database=WEBDB;uid=sa;pwd=123");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Tcomment>(entity =>
            {
                entity.HasKey(e => e.CommentId)
                    .HasName("PK__TComment__C3B4DFAA7ACF5F42");

                entity.ToTable("TComment");

                entity.Property(e => e.CommentId).HasColumnName("CommentID");

                entity.Property(e => e.CommentContent).HasColumnType("text");

                entity.Property(e => e.CommentTime).HasColumnType("datetime");

                entity.Property(e => e.CommentUser).HasMaxLength(30);

                entity.Property(e => e.MessageId).HasColumnName("MessageID");
            });

            modelBuilder.Entity<TmessCategory>(entity =>
            {
                entity.HasKey(e => e.CategoryId)
                    .HasName("PK__TMessCat__19093A2BD133F85D");

                entity.ToTable("TMessCategory");

                entity.Property(e => e.CategoryId).HasColumnName("CategoryID");

                entity.Property(e => e.Category)
                    .IsRequired()
                    .HasMaxLength(30);

                entity.Property(e => e.CategoryEnable)
                    .IsRequired()
                    .HasMaxLength(10);
            });

            modelBuilder.Entity<Tmessage>(entity =>
            {
                entity.HasKey(e => e.MessageId)
                    .HasName("PK__TMessage__C87C037C17F56412");

                entity.ToTable("TMessage");

                entity.Property(e => e.MessageId).HasColumnName("MessageID");

                entity.Property(e => e.GuestName).HasMaxLength(30);

                entity.Property(e => e.IsPase).HasMaxLength(30);

                entity.Property(e => e.LastCommentTime).HasColumnType("datetime");

                entity.Property(e => e.MessageContent).HasColumnType("text");

                entity.Property(e => e.MessageKind).HasMaxLength(30);

                entity.Property(e => e.MessageTime).HasColumnType("datetime");

                entity.Property(e => e.MessageTitle).HasMaxLength(30);

                entity.Property(e => e.Reply).HasColumnType("text");
            });

            modelBuilder.Entity<Uinformation>(entity =>
            {
                entity.HasKey(e => e.UserName)
                    .HasName("PK__Uinforma__C9F284570B7BF0F6");

                entity.Property(e => e.UserName).HasMaxLength(20);

                entity.Property(e => e.UinformationId)
                    .HasColumnName("UinformationID")
                    .ValueGeneratedOnAdd();

                entity.Property(e => e.UserAge).HasColumnType("datetime");

                entity.Property(e => e.UserIp).HasMaxLength(100);

                entity.Property(e => e.UserLoginTime).HasColumnType("datetime");

                entity.Property(e => e.UserRegisterTime).HasColumnType("datetime");

                entity.Property(e => e.Useravatar).HasColumnType("text");
            });

            modelBuilder.Entity<Userinfo>(entity =>
            {
                entity.HasKey(e => e.UserName)
                    .HasName("PK__userinfo__C9F284579D6FAA73");

                entity.ToTable("userinfo");

                entity.Property(e => e.UserName).HasMaxLength(20);

                entity.Property(e => e.UserEmail).HasMaxLength(120);

                entity.Property(e => e.UserEnable).HasMaxLength(10);

                entity.Property(e => e.UserId)
                    .HasColumnName("UserID")
                    .ValueGeneratedOnAdd();

                entity.Property(e => e.UserMember).HasMaxLength(10);

                entity.Property(e => e.UserPwd)
                    .IsRequired()
                    .HasMaxLength(50);
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
